package notes.java.sjms23.t10_visitor;

// 具体访问者，计算周长
public class VisitorPerimeter implements Visitor{

    @Override
    public double ofShap(ShapeTriangle triangle) {
        // 三角形周长
        double len = triangle.getA() + triangle.getB() + triangle.getC();
        System.out.println("三角形周长： " + len);
        return len;
    }

    @Override
    public double ofShap(ShapeSquare square) {
        // 长方形周长
        double len = 2*(square.getA() + square.getB());
        System.out.println("长方形周长：" + len);
        return len;
    }

    @Override
    public double ofShap(ShapeCircle circle) {
        // 圆形周长
        double len = 2*Math.PI*circle.getR();
        System.out.println("圆形周长：" + len);
        return len;
    }

}
